//package cn.zsb.zsb.ctrl;
//
//import cn.zsb.zsb.entity.User;
//import org.springframework.beans.propertyeditors.CustomDateEditor;
//import org.springframework.stereotype.Controller;
//import org.springframework.ui.Model;
//import org.springframework.web.bind.WebDataBinder;
//import org.springframework.web.bind.annotation.*;
//import org.springframework.web.filter.CharacterEncodingFilter;
//
//import javax.servlet.http.HttpServletRequest;
//import javax.servlet.http.HttpServletResponse;
//import javax.servlet.http.HttpSession;
//import java.io.UnsupportedEncodingException;
//import java.text.SimpleDateFormat;
//import java.util.Date;
//
///**
// * @author oldliu
// * @since 1.0
// */
//@Controller
//@RequestMapping("user")
//public class UserController2 {
//    @PostMapping("login")
//    public String login(@RequestParam(name = "username", required = false) String username, String pass,
//                        HttpServletRequest request) {
//
//        if (username.startsWith("java82") && "1234".equals(pass)) {
//            request.getSession().setAttribute("USER_LOGIN", username);
//            return "forward:/welcome.jsp";
//        }
//        request.setAttribute("tip", "错误的用户名或者密码！");
//        return "forward:/login.jsp";
//    }
//
//    @PostMapping("reg")
//    public String reg(@ModelAttribute User user, Model m) {
//        System.out.println("注册信息：" + user);
//        m.addAttribute("msg", "用户：" + user.getUsername() + "注册成功");
//        return "forward:/registersucc.jsp";
//    }
////    public void reg(@ModelAttribute User user, HttpServletResponse req){
////        System.out.println("注册信息："+user);
////        req.sendRedirect("xxx.jsp");
////    }
//
//    @InitBinder
//    public void initBinder(WebDataBinder binder) {
//        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd'T'hh:mm");
//        //binder.registerCustomEditor(Date.class, new CustomDateEditor(dateFormat, true));
//        binder.registerCustomEditor(Date.class,"addTime", new CustomDateEditor(dateFormat, true));
//        // true:允许输入空值，false:不能为空值 }
//    }
//}